// pages/equipItem/equipItem.js
const app = getApp()
const util = require('../../utils/util.js')
const lbbService = require('../service/service.js')
var Base64 = require('../../utils/base64.js')

Page({

  /**
   * 页面的初始数据
   */
  data: {

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let that = this
    that.setData({
      equipCode: options.equipCode,
      eqtModelName: options.eqtModelName,
      hospitalName: options.hospitalName,
      equHospitalName: options.equHospitalName,
      scrollHeight: app.getScrollHeight()-58
    })
    let equipCode = that.data.equipCode.replace(/L/ig, "")
    wx.setNavigationBarTitle({
      title: 'L' + equipCode + '租借记录'
    })
    lbbService.getRentRecord({ equId: equipCode }, function(res){
      that.setData({
        recordList: res.data.leaseRecordInfos,
        onlineTime: res.data.startUsingTime,
        equStat: res.data.equStat
      })
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  toDetail:function(e){
    console.log(e)
    let that = this
    let time = e.currentTarget.dataset.time
    let content = Base64.encode(e.currentTarget.dataset.content)
    wx.navigateTo({
      url: '../recordDetail/recordDetail?time=' + time + '&content=' + content + '&equipCode=' + that.data.equipCode.replace(/[^0-9]/ig, ""),
    })
  },

  toSearch:function(){
    var that = this;
    wx.navigateTo({
      url: '../equipItem/equipItem?' + 'equipCode=' + that.data.equipCode.replace(/[^0-9]/ig, ""),
    })
  }
})